﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataLayer.Entities;
using NHibernate.Criterion;

namespace DataLayer.Implementations
{
    public class DonutPrefApplication : GeneralApplication<DonutPreference>
    {
        public IList<DonutPreference> GetByUserId(int userId)
        {
            List<ICriterion> conditions = new List<ICriterion>();
            conditions.Add(Restrictions.Eq("User.UserId", userId));

            return model.GetByCriterion<DonutPreference>(conditions).ToList();
        }

        public void Save(DonutPreference donut)
        {
            if (donut.DonutPreferenceId == null)
            {
                Save(donut, 0);
            }
            else
            {
                Save(donut, donut.DonutPreferenceId.Value);
            }
        }
    }
}
